﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.Model.Cms;
using Com.Dal.Cms;
namespace Com.Bll.Cms
{
    public class CmsTreeOperater
    {
        private CmsTreeHelper CmsTreeHelper = new CmsTreeHelper();
        /// <summary>
        /// 根据一个结点 id,得到一个结点实体 
        /// </summary>
        /// <param name="id">结点id</param>
        /// <returns></returns>
        public Cms_Tree GetNode(int id)
        {
            Cms_Tree node = null;
            try
            {
                node = CmsTreeHelper.Find(id);
            }
            catch
            {
                if (node == null)
                {
                    node = new Cms_Tree();
                }
            }
            return node;
        }


        /// <summary>
        /// 根据一个结点id,得到该结点下的所有子结点
        /// </summary>
        /// <param name="id">当前结点id</param>
        /// <returns>该结点下的所有子结点</returns>
        public List<Cms_Tree> GetChildNodes(int id)
        {
            List<Cms_Tree> lst = new List<Cms_Tree>();
            try
            {
                lst = CmsTreeHelper.FindList(item => item.ParentNodeId == id).ToList();
            }
            catch
            {
                lst = new List<Cms_Tree>();
            }
            return lst;
        }


    }
}
